home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / shell / dialog-0.000 / dialog-0 / dialog-0.6c / dialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-18  |  6.4 KB  |  237 lines

  1. /*
  2.  *  dialog.h -- common declarations for all dialog modules
  3.  *
  4.  *  AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
  5.  *
  6.  *  This program is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU General Public License
  8.  *  as published by the Free Software Foundation; either version 2
  9.  *  of the License, or (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #include <sys/types.h>
  22. #include <fcntl.h>
  23. #include <unistd.h>
  24. #include <ctype.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27.  
  28. #ifdef ultrix
  29. #include <cursesX.h>
  30. #else
  31. #include <curses.h>
  32. #endif
  33.  
  34. /*
  35.  * Change these if you want
  36.  */
  37. #define USE_SHADOW FALSE
  38. #define USE_COLORS TRUE
  39.  
  40.  
  41. #define ESC 27
  42. #define TAB 9
  43. #define MAX_LEN 2048
  44. #define BUF_SIZE (10*1024)
  45. #define MIN(x,y) (x < y ? x : y)
  46. #define MAX(x,y) (x > y ? x : y)
  47.  
  48.  
  49. #ifndef HAVE_NCURSES
  50. #ifndef ACS_ULCORNER
  51. #define ACS_ULCORNER '+'
  52. #endif
  53. #ifndef ACS_LLCORNER
  54. #define ACS_LLCORNER '+'
  55. #endif
  56. #ifndef ACS_URCORNER
  57. #define ACS_URCORNER '+'
  58. #endif
  59. #ifndef ACS_LRCORNER
  60. #define ACS_LRCORNER '+'
  61. #endif
  62. #ifndef ACS_HLINE
  63. #define ACS_HLINE '-'
  64. #endif
  65. #ifndef ACS_VLINE
  66. #define ACS_VLINE '|'
  67. #endif
  68. #ifndef ACS_LTEE
  69. #define ACS_LTEE '+'
  70. #endif
  71. #ifndef ACS_RTEE
  72. #define ACS_RTEE '+'
  73. #endif
  74. #ifndef ACS_UARROW
  75. #define ACS_UARROW '^'
  76. #endif
  77. #ifndef ACS_DARROW
  78. #define ACS_DARROW 'v'
  79. #endif
  80. #endif
  81.  
  82. /* 
  83.  * Attribute names
  84.  */
  85. #define screen_attr                   attributes[0]
  86. #define shadow_attr                   attributes[1]
  87. #define dialog_attr                   attributes[2]
  88. #define title_attr                    attributes[3]
  89. #define border_attr                   attributes[4]
  90. #define button_active_attr            attributes[5]
  91. #define button_inactive_attr          attributes[6]
  92. #define button_key_active_attr        attributes[7]
  93. #define button_key_inactive_attr      attributes[8]
  94. #define button_label_active_attr      attributes[9]
  95. #define button_label_inactive_attr    attributes[10]
  96. #define inputbox_attr                 attributes[11]
  97. #define inputbox_border_attr          attributes[12]
  98. #define searchbox_attr                attributes[13]
  99. #define searchbox_title_attr          attributes[14]
  100. #define searchbox_border_attr         attributes[15]
  101. #define position_indicator_attr       attributes[16]
  102. #define menubox_attr                  attributes[17]
  103. #define menubox_border_attr           attributes[18]
  104. #define item_attr                     attributes[19]
  105. #define item_selected_attr            attributes[20]
  106. #define tag_attr                      attributes[21]
  107. #define tag_selected_attr             attributes[22]
  108. #define tag_key_attr                  attributes[23]
  109. #define tag_key_selected_attr         attributes[24]
  110. #define check_attr                    attributes[25]
  111. #define check_selected_attr           attributes[26]
  112. #define uarrow_attr                   attributes[27]
  113. #define darrow_attr                   attributes[28]
  114.  
  115. /* number of attributes */
  116. #define ATTRIBUTE_COUNT               29
  117.  
  118. /*
  119.  * Global variables
  120.  */
  121. #ifdef HAVE_NCURSES
  122. extern bool use_colors;
  123. extern bool use_shadow;
  124. #endif
  125.  
  126. extern chtype attributes[];
  127.  
  128. extern const char *backtitle;
  129.  
  130. /*
  131.  * Function prototypes
  132.  */
  133. #ifdef HAVE_NCURSES
  134. extern void create_rc (const char *filename);
  135. extern int parse_rc (void);
  136. #endif
  137.  
  138.  
  139. void init_dialog (void);
  140. void end_dialog (void);
  141. void attr_clear (WINDOW * win, int height, int width, chtype attr);
  142. void dialog_clear (void);
  143. #ifdef HAVE_NCURSES
  144. void color_setup (void);
  145. #endif
  146. void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x);
  147. void print_button (WINDOW * win, const char *label, int y, int x, int selected);
  148. void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box,
  149.         chtype border);
  150. #ifdef HAVE_NCURSES
  151. void draw_shadow (WINDOW * win, int y, int x, int height, int width);
  152. #endif
  153.  
  154. int dialog_yesno (const char *title, const char *prompt, int height, int width);
  155. int dialog_msgbox (const char *title, const char *prompt, int height,
  156.         int width, int pause);
  157. int dialog_textbox (const char *title, const char *file, int height, int width);
  158. int dialog_menu (const char *title, const char *prompt, int height, int width,
  159.         int menu_height, int item_no, const char * const * items);
  160. int dialog_checklist (const char *title, const char *prompt, int height,
  161.         int width, int list_height, int item_no,
  162.         const char * const * items, int flag, int separate_output);
  163. extern unsigned char dialog_input_result[];
  164. int dialog_inputbox (const char *title, const char *prompt, int height,
  165.         int width, const char *init);
  166. int dialog_guage (const char *title, const char *prompt, int height, int width,
  167.         int percent);
  168.  
  169. /*
  170.  * The following stuff is needed for mouse support
  171.  */
  172. #ifndef HAVE_LIBGPM
  173.  
  174. extern __inline__ void
  175. mouse_open (void)
  176. {
  177. };
  178. extern __inline__ void
  179. mouse_close (void)
  180. {
  181. };
  182. extern __inline__ void
  183. mouse_mkregion (int y, int x, int height, int width,
  184.         int code)
  185. {
  186. };
  187. extern __inline__ void
  188. mouse_mkbigregion (int y, int x, int height, int width,
  189.            int nitems, int th, int mode)
  190. {
  191. };
  192. extern __inline__ void
  193. mouse_setbase (int x, int y)
  194. {
  195. };
  196. extern __inline__ int
  197. mouse_wgetch (WINDOW * win)
  198. {
  199. };
  200.  
  201. #define mouse_wgetch(w) wgetch(w)
  202.  
  203. #else
  204.  
  205. void mouse_open (void);
  206. void mouse_close (void);
  207. void mouse_mkregion (int y, int x, int height, int width, int code);
  208. void mouse_mkbigregion (int y, int x, int height, int width, int nitems,
  209.             int th, int mode);
  210. void mouse_setbase (int x, int y);
  211. int mouse_wgetch (WINDOW *);
  212. int Gpm_Wgetch (WINDOW * w);
  213. #define mouse_wgetch(w) Gpm_Wgetch(w)
  214.  
  215. #endif
  216.  
  217. #define mouse_mkbutton(y,x,len,code) mouse_mkregion(y,x,1,len,code);
  218.  
  219. /*
  220.  * This is the base for fictious keys, which activate
  221.  * the buttons.
  222.  *
  223.  * Mouse-generated keys are the following:
  224.  *   -- the first 32 are used as numbers, in addition to '0'-'9'
  225.  *   -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o')
  226.  *   -- uppercase chars are used to invoke the button (M_EVENT + 'O')
  227.  */
  228. #define M_EVENT (KEY_MAX+1)
  229.  
  230.  
  231. /*
  232.  * The `flag' parameter in checklist is used to select between
  233.  * radiolist and checklist
  234.  */
  235. #define FLAG_CHECK 1
  236. #define FLAG_RADIO 0
  237.